﻿using DAO.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO
{
    public class DataManager
    {
        private BuildParametersRepository _buildParametersDao;
        private CustomizationRepository _customizationDao;
        private ServerRepository _serverDao;
        private ServerObjectsRepository _serverObjectsDao;
        private ServerTypeRepository _serverTypeDao;
        private OperationRepository _operationRepository;
        private TemplateRepository _templateRepository;
        private DeployAppEntities dp;
        private DeployObjectsTypesRepository _deployObjectsTypesRepository;
        private DeployParametersRepository _deployParametersRepository;
        private SvnParametersRepository _svnParametersRepository;
        private VersionsHistoryRepository _versionsHistoryRepository;
        private NotificationsRepository _notificationsRepository;
        private NotificationsApplicationsRepository _notificationsApplicationsrepository;
        private ReportsRepository _reportsRepository;

        public DataManager()
        {
            dp = new DeployAppEntities();
        }

        public ReportsRepository ReportsManager
        {
            get
            {
                if (_reportsRepository == null)
                    _reportsRepository = new ReportsRepository(dp);
                return _reportsRepository;
            }
        }

        public NotificationsApplicationsRepository NotificationsApplicationsManager
        {
            get
            {
                if (_notificationsApplicationsrepository == null)
                    _notificationsApplicationsrepository = new NotificationsApplicationsRepository(dp);
                return _notificationsApplicationsrepository;
            }
        }

        public NotificationsRepository NotificationsManager
        {
            get
            {
                if (_notificationsRepository == null)
                    _notificationsRepository = new NotificationsRepository(dp);
                return _notificationsRepository;
            }
        }

        public VersionsHistoryRepository VersionsHistoryManager
        {
            get
            {
                if (_versionsHistoryRepository == null)
                    _versionsHistoryRepository = new VersionsHistoryRepository(dp);
                return _versionsHistoryRepository;
            }
        }

        public SvnParametersRepository SvnParametersManager
        {
            get
            {
                if (_svnParametersRepository == null)
                    _svnParametersRepository = new SvnParametersRepository(dp);
                return _svnParametersRepository;
            }
        }

        public DeployParametersRepository DeployParametersManager
        {
            get
            {
                if (_deployParametersRepository == null)
                    _deployParametersRepository = new DeployParametersRepository(dp);
                return _deployParametersRepository;
            }
        }

        public BuildParametersRepository BuildParametersManager 
        { 
            get 
            {
                if (_buildParametersDao == null)
                    _buildParametersDao = new BuildParametersRepository(dp);
                return _buildParametersDao;
            }  
        }

        public CustomizationRepository CustomizationManager
        {
            get
            {
                if (_customizationDao == null)
                    _customizationDao = new CustomizationRepository(dp);
                return _customizationDao;
            }
        }

        public ServerRepository ServerManager 
        {
            get
            {
                if (_serverDao == null)
                    _serverDao = new ServerRepository(dp);
                return _serverDao;
            } 
        }

        public ServerObjectsRepository ServerObjectsManager
        {
            get
            {
                if (_serverObjectsDao == null)
                    _serverObjectsDao = new ServerObjectsRepository(dp);
                return _serverObjectsDao;
            }
        }

        public ServerTypeRepository ServerTypeManager
        {
            get
            {
                if (_serverTypeDao == null)
                    _serverTypeDao = new ServerTypeRepository(dp);
                return _serverTypeDao;
            }
        }

        public OperationRepository OperationManager
        {
            get
            {
                if (_operationRepository == null)
                    _operationRepository = new OperationRepository(dp);
                return _operationRepository;
            }
        }

        public TemplateRepository TemplateManager
        {
            get
            {
                if (_templateRepository == null)
                    _templateRepository = new TemplateRepository(dp);
                return _templateRepository;
            }
        }

        public DeployObjectsTypesRepository DeployObjectsTypesManager
        {
            get
            {
                if (_deployObjectsTypesRepository == null)
                    _deployObjectsTypesRepository = new DeployObjectsTypesRepository(dp);
                return _deployObjectsTypesRepository;
            }
        }

        public void SaveChanges()
        {
            dp.SaveChanges();
        }
    }
}
